package com;

import org.json.JSONException;
import org.json.JSONObject;

public class MsgObj {
	private String type;
	private String v1;
	private String v2;

	public static MsgObj fromJson(String json) throws JSONException {
		JSONObject jo = new JSONObject(json);
		MsgObj res = new MsgObj();
		res.setType(jo.getString("type"));
		if (jo.has("v1")) {
			res.setV1(jo.getString("v1"));
		}
		if (jo.has("v2")) {
			res.setV2(jo.getString("v2"));
		}
		return res;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getV1() {
		return v1;
	}

	public void setV1(String v1) {
		this.v1 = v1;
	}

	public String getV2() {
		return v2;
	}

	public void setV2(String v2) {
		this.v2 = v2;
	}
}
